'''

@author: noako
'''
import unittest
from CG.SS.DCEL import HalfEdge, Vertex
from CG.SS.GeometryHelper import Point, SupportingLine
from CG.SS.FuzzyFloat import FuzzyFloat


class Test(unittest.TestCase):


    def setUp(self):
        self.edge = HalfEdge(Vertex(Point(FuzzyFloat(0),FuzzyFloat(0))), 1)


    def tearDown(self):
        pass


    def testSupportingLine1(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(1),FuzzyFloat(2)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, 0.447213595)
        self.assertEqual(line.p1.x, -0.894427190)
        
    def testSupportingLine2(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(-1),FuzzyFloat(2)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, -0.447213595)
        self.assertEqual(line.p1.x, -0.894427190)
        
    def testSupportingLine3(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(-1),FuzzyFloat(-2)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, -0.447213595)
        self.assertEqual(line.p1.x, 0.894427190)
        
    def testSupportingLine4(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(1),FuzzyFloat(-2)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, 0.447213595)
        self.assertEqual(line.p1.x, 0.894427190)
        
    def testSupportingLine5(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(1),FuzzyFloat(0)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, 1)
        self.assertEqual(line.p1.x, 0)
        
    def testSupportingLine6(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(-1),FuzzyFloat(0)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, -1)
        self.assertEqual(line.p1.x, 0)
                
    def testSupportingLine7(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(0),FuzzyFloat(1)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, 0)
        self.assertEqual(line.p1.x, -1)
        
    def testSupportingLine8(self):
        self.edge.destination = lambda: Vertex(Point(FuzzyFloat(0),FuzzyFloat(-1)))
        line = SupportingLine(self.edge, 1)
        self.assertEqual(line.p1.y, 0)
        self.assertEqual(line.p1.x, 1)
        

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testSupportingEdge']
    unittest.main()